home *** CD-ROM | disk | FTP | other *** search
/ Aminet 4 / Aminet 4 - November 1994.iso / aminet / comm / bbs / fax_it_cnet.lzh / FAX-IT / autofax.gpf < prev    next >
Text File  |  1994-10-02  |  5KB  |  197 lines

  1. /*
  2.  * AutoFAX has no information for you as the sysop to edit
  3.  *
  4.  * Go change the FAX-Times file and leave this one alone...
  5.  *
  6.  *
  7.  * This is the program that converts the FAX TEXT into a FAX 
  8.  * then tries to send it out.
  9.  */
  10.  
  11. options results
  12.  
  13. /* Check to be sure GPFax is even running.... 
  14.  */
  15. if show(prorts,REXX_GPFAX) ~= 1 then exit
  16.  
  17. Version='FAX-IT v2.5   -*-   AutoFAX v2.5   -*-   By: Glenn J. Schworak'
  18.  
  19. Address cnetRexx0
  20. GetUser 1307954 ; UserDir = Result
  21. Doors   = 'Doors:' ; GPF = 'Doors:Fax-IT/'
  22. LogFAX = 'Logs:FAX.log'
  23. FaxIT         = Doors'Fax-IT/'
  24. Times         = FaxIT'FAX-Times'
  25. Messages  = FaxIT'Text/'
  26. Numbers   = FaxIT'Numbers/'
  27.  
  28.  
  29. /* As in the DataCall.gpf file, we set a file in the T: directory to keep
  30.  * any other FAX-IT programs from trying to access GPFax while we are
  31.  * working
  32.  */
  33. Shell Command 'C:Echo >t:FAXnode ""'
  34.  
  35.  
  36.  
  37.  
  38. /*
  39.  * Edit the file "FAX-Times" to configure the correct times for your
  40.  * FAX modem to attempt to dial. These times will not stop a user from
  41.  * typing a FAX message, just keep the system from calling out right away.
  42.  */
  43.  
  44. stat=Exists(Times)
  45. if stat~=1 then do
  46.     address command 'Echo >>'LogFAX' "b1c1ERROR: c6The c3FAX-Times c6file is missing from the FAX-IT door area...w2q1"'
  47.     exit
  48. end
  49. Open(tempfile,Times,'read') 
  50.     hours=readln(tempfile)
  51.     days=readln(tempfile)    
  52. Close(tempfile)
  53.  
  54.  
  55. Now = '-'Time('Hours')'-'
  56. Day = SubStr(Date('W'),1,3)
  57.  
  58.  
  59. Force="*"
  60. stat=Exists("T:FAX-NOW") 
  61. if stat=1 then do
  62.     Open(tempfile,"T:FAX-NOW",'read') 
  63.         Force=readln(tempfile)
  64.     Close(tempfile)
  65.     Shell Command "C:Delete T:FAX-NOW"
  66. end
  67.  
  68.  
  69. Open(tempfile,'T:TryFAX','write') ; Close(tempfile)
  70.  
  71. Do While Exists('T:TryFAX')='1'
  72.     Address Command 'c:Delete t:TryFAX'
  73.     if Force="*" then do
  74.         If Index(Hours,Now)=0 | Index(Days,Day)=0 Then Call Quit
  75.         Address Command 'c:List >T:FAX-List 'Messages'GJSFAX#?.#? Lformat "%S"'
  76.         end
  77.     else do
  78.         Address Command 'C:Echo >T:FAX-List 'Force
  79.     end
  80.     Address rexx_gpfax
  81.  
  82.     File = Open(ListFile,'T:FAX-List','READ')
  83.     If File~=1 Then Call Quit
  84.  
  85.     Do Until EOF(ListFile)
  86.         TextFile = ReadLN(ListFile)
  87.         convert Messages||TextFile
  88.           File = Open(Text,Messages||TextFile,'READ')
  89.           if File=1 Then do
  90.          FAXNUM = ReadLN(Text)
  91.          txt=''
  92.           FAXed='FAXed Out: 'Time('Civil')'  'Date('Normal')
  93.           do while Index(txt,"TO:")<1      
  94.             txt = ReadLN(Text)
  95.          end
  96.           TO='       'Strip(txt)
  97.        do while Index(txt,"FAX:")<1     
  98.           txt = ReadLN(Text) 
  99.        end
  100.           FAX='      'Strip(txt)
  101.        do while Index(txt,"SUBJECT:")<1 
  102.           txt = ReadLN(Text) 
  103.        end
  104.           Subject='  'Strip(txt)
  105.        do while Index(txt,"FROM:")<1    
  106.           txt = ReadLN(Text) 
  107.        end
  108.         FROM2=txt 
  109.        UserNum=Strip(SubStr(txt'          ',Index(txt,#)+1,10))
  110.        do while Index(txt,"WRITTEN:")<1 
  111.           txt = ReadLN(Text) 
  112.        end
  113.           Written='  'Strip(txt)
  114.        Close(Text)
  115.           SendF = 'GPFax:FAX_OUT/'TextFile'_TFAX'
  116.        SendFAX SendF' to 'Compress(FAXNUM)
  117.           Stat=''
  118.           ReportLog T 3
  119.           Stat=result
  120.           File2 = open(StatFile,UserDir'FaxStatus','Append')
  121.           if File2 = 0 then File2 = open(StatFile,UserDir'FaxStatus','Write')
  122.        if SubStr(Stat,1,4)='OK.S' then do
  123.          if File2 = 1 then call FAXGOOD
  124.          end 
  125.        else do
  126.             if File2 = 1 then Call FAXBAD
  127.          address command 'c:copy 'Messages||TextFile' to 'UserDir
  128.        end
  129.        if File2 = 1 then do
  130.             WriteLN(StatFile,'02}n1k4-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-q1')
  131.          end
  132.          if File2 = 1 then Close(StatFile)
  133.       end 
  134.       address command 'c:delete >NIL: 'Messages||TextFile
  135.     end 
  136.   Close(ListFile)
  137.  
  138.   address command 'c:delete GPFax:FAX_OUT/GJSFAX#?.p#?'
  139.   address command 'c:delete T:FAXnode'
  140. end
  141. call Quit
  142.  
  143.  
  144. Quit:
  145.   address command 'c:delete t:#?FAX#?'
  146. exit
  147.  
  148.  
  149. FAXGOOD:
  150.   If ~Exists(Numbers||FAXNUM) then do
  151.       open(NumFile,Numbers||FAXNUM,'Write')
  152.       WriteLN(NumFile,'k1---k0c1 NUMBER IS UNKNOWN TO THIS SYSTEMk1 ---k0q1')
  153.       close(NumFile)
  154.   end
  155.   WriteLN(StatFile,'n3c3This FAX was successfully sent....   'FAXed)
  156.   WriteLN(StatFile,'n1c2'TO'n1'FAX'n1'Subject'n1'Written)
  157.   call StartFile
  158.   open(LogFile,LogFAX,'Append')
  159.   WriteLN(LogFile,'n2c2---SUCCESSFUL---n1q1  'From2'n1'TO'n1'FAX'n1'Subject'n1'Written)
  160.   numf=open(NumFile,Numbers||FAXNUM,'Read')
  161.   if numf=1 then do
  162.     Pre='     NOTE:c6 '
  163.     do while ~eof(numfile)
  164.         txt=ReadLN(numfile)
  165.        WriteLN(StatFile,Pre||txt)
  166.        WriteLN(LogFile,Pre||txt)
  167.         Pre='           '
  168.     end
  169.     close(numfile)
  170.   end
  171.   close(LogFile)
  172.   Return
  173.  
  174.  
  175. FAXBAD:
  176.   WriteLN(StatFile,'n3c3This FAX failed to send....  'time('civil'))
  177.   WriteLN(StatFile,'n1c1'TO'n1'FAX'n1'Subject'n1'Written'n2')
  178.   WriteLN(StatFile,'--FAILED--')
  179.   WriteLN(StatFile,TextFile)
  180.   open(LogFile,LogFAX,'Append')
  181.   WriteLN(LogFile,'n2c1---FAILED---n1q1  'From2'n1'TO'n1'FAX'n1'Subject'n1'Written)
  182.   close(LogFile)
  183.   Return
  184.  
  185.  
  186. StartFile:
  187.     if ~exists(LogFAX) then do
  188.         open(LogFile,LogFAX,'Write')
  189.         WriteLN(LogFile,'f1q1'Version'n2Started: 'Date(n)'  -*-  'Time(c)'n2')
  190.         close(LogFile)
  191.     end
  192.     return
  193.     
  194.  
  195. Quit:
  196.     exit
  197.